#ifndef CUSTOMTOAST_H
#define CUSTOMTOAST_H


#include <QLabel>
#include <QTimer>
#include <QDebug>

class CustomToast : public QWidget{

    Q_OBJECT

public:
    enum Alignment : quint8 {
        Center = 0,
        CenterTop,
        Custom
    };

public:
    explicit CustomToast(QWidget *parent = nullptr);
    ~CustomToast();

public:
    void setText(const QString &text);                 // 设置文本内容
    void setFontColor(const QColor &color);            // 设置字体颜色
    void setFontSize(int px);                          // 设置字体大小
    void setBackgroundColor(const QColor &color);      // 设置背景颜色
    void setAlignment(const Alignment &align);         // 设置显示位置
    void setDuration(int msec);                        // 设置动画持续时间
    void setCustomAlign(int x, int startY, int endY);  // 设置自定义显示位置

protected:
    void showEvent(QShowEvent *event) override;

private:
    QLabel *m_labelContext;
    Alignment m_align;
    int m_duration;
    QColor m_fontColor;
    int m_fontSize;
    QColor m_backgroundColor;

    int m_customX;
    int m_customStartY;
    int m_customEndY;
};

#endif // CUSTOMTOAST_H
